<!-- 设备管理-设备列表页面 -->
<template>
  <div class="app-container">
    <px-form v-show="showSearch" ref="queryRef" class="custom-form-ui" :model="queryParams" :inline="true" label-width="90px">
      <px-form-item style="width: 310px !important" label="系统">
        <px-tree-select
          v-model="queryParams.systemCode"
          clearable
          style="width: 100%"
          placeholder="请选择设备系统（树状图）"
          :props="defaultProps"
          :data="systemList"
        />
      </px-form-item>
      <px-form-item label="仪表名称">
        <px-select v-model="queryParams.eqpName" placeholder="请选择" clearable filterable>
          <px-option v-for="(item, index) in EqpNameList" :key="index" :label="item" :value="item" />
        </px-select>
      </px-form-item>
      <px-form-item label="仪表编码">
        <px-select v-model="queryParams.eqpCode" placeholder="请选择" clearable filterable>
          <px-option v-for="(item, index) in EqpCodeList" :key="index" :label="item" :value="item" />
        </px-select>
      </px-form-item>
      <px-form-item label="计划时间" style="width: 440px !important">
        <px-date-picker
          v-model="dateRange"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          placeholder="请选择"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
        />
      </px-form-item>
      <px-button style="margin-top: -17px" type="primary" icon="" @click="handleQuery('search')">搜索</px-button>
      <px-button style="margin-top: -17px" icon="" @click="resetQuery">重置</px-button>
    </px-form>
    <px-row :gutter="10" class="mb8">
      <px-col :span="1.5">
        <px-button v-has="'EXECUTE_ADD'" type="primary" icon="" @click="handleAddPlan">新增</px-button>
      </px-col>
    </px-row>
    <px-table v-loading="loading" :data="typeList" height="calc(100vh - 319px)" border @selection-change="handleSelectionChange">
      <px-table-column label="序号" width="60" align="center" fixed="left">
        <template #default="{ $index }">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
        </template>
      </px-table-column>
      <px-table-column label="系统" fixed="left" show-overflow-tooltip min-width="170" prop="systemName">
        <template #default="scope">
          <span>{{ scope.row.systemName }}</span>
        </template>
      </px-table-column>
      <px-table-column label="仪表名称" fixed="left" show-overflow-tooltip min-width="170" prop="eqpName">
        <template #default="scope">
          <span>{{ scope.row.eqpName ? scope.row.eqpName : "-" }}</span>
        </template>
      </px-table-column>

      <px-table-column label="仪表编码" fixed="left" show-overflow-tooltip min-width="170" prop="eqpCode">
        <template #default="scope">
          <span>{{ scope.row.eqpCode ? scope.row.eqpCode : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="指标名称" fixed="left" show-overflow-tooltip min-width="170" prop="pointName">
        <template #default="scope">
          <span>{{ scope.row.pointName ? scope.row.pointName : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column v-for="(items, index) in typeList[0]?.dateList" :key="index" class="planrow" width="121" :label="items.date">
        <template #default="scope">
          <span style="position: absolute; top: 0; left: 0; display: inline-block; width: 120px; height: 35px">
            <span
              v-for="(item, index) in scope.row?.dateList.filter(item => item.date == items.date)[0].timeList"
              :key="index"
              style="display: inline-block; width: 5px"
            >
              <span v-if="item.scheduledId == null" style="display: inline-block; width: 5px; height: 35px" />
              <span
                v-if="item.scheduledId != null && item.planName == null"
                style="display: inline-block; width: 5px; height: 35px; cursor: pointer; background: #2563eb"
              />
              <px-tooltip class="box-item" trigger="click" :content="item.planName ? item.planName : '-'" placement="top">
                <span
                  v-if="item.scheduledId != null && item.planName != null"
                  style="display: inline-block; width: 5px; height: 35px; cursor: pointer; background: #2563eb"
                />
              </px-tooltip>
            </span>
          </span>
        </template>
      </px-table-column>
      <px-table-column fixed="right" label="操作" align="center" width="140">
        <template #default="scope">
          <px-button v-has="'EXECUTE_SCHEDULING'" link type="primary" @click="handleDetail(scope.row)">
            <px-tooltip class="box-item" content="排期" placement="top">
              <px-icon><Tickets /></px-icon> </px-tooltip
          ></px-button>
        </template>
      </px-table-column>
      <template #empty>
        <px-empty :image-size="150" />
      </template>
    </px-table>

    <pagination
      v-if="!equipopen && !equipopenDetail"
      v-show="total > 0"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      style="margin-bottom: -10px"
      :total="total"
      @pagination="getList"
    />
    <px-dialog v-model="equipopen" draggable clickHideContent width="1000" :close-on-click-modal="false" title="仪表排期" align-center>
      <px-row :gutter="10" class="mb8">
        <px-col :span="1.5">
          <px-button type="primary" icon="" @click="handleAdd">新增</px-button>
        </px-col>
      </px-row>
      <px-table style="margin-top: 20px" :data="dataplanList" height="480px" border>
        <px-table-column label="序号">
          <template #default="scope">
            <px-tooltip :content="scope.row.id" placement="top" effect="light">
              <span>{{ scope.$index + 1 || "--" }}</span>
            </px-tooltip>
          </template>
        </px-table-column>

        <px-table-column label="验证计划名称" prop="planName">
          <template #default="scope">
            <span>{{ scope.row.planName }}</span>
          </template>
        </px-table-column>
        <px-table-column label="开始时间" prop="startTime">
          <template #default="scope">
            <span>{{ scope.row.startTime }}</span>
          </template>
        </px-table-column>
        <px-table-column label="结束时间" prop="endTime">
          <template #default="scope">
            <span>{{ scope.row.endTime }}</span>
          </template>
        </px-table-column>
        <px-table-column label="创建人" prop="systemName">
          <template #default="scope">
            <span>{{ scope.row.creator ? scope.row.creator : "-" }}</span>
          </template>
        </px-table-column>
        <px-table-column fixed="right" label="操作" align="center" width="140">
          <template #default="scope">
            <px-button v-if="scope.row.creatorId == userId" link type="primary" @click="handleEditor(scope.row)">
              <px-tooltip class="box-item" content="编辑" placement="top">
                <px-icon><EditPen /></px-icon> </px-tooltip
            ></px-button>
            <px-button v-if="scope.row.creatorId == userId" link type="danger" @click="handleDelete(scope.row)"
              ><px-tooltip class="box-item" content="删除" placement="top">
                <px-icon><Delete /></px-icon> </px-tooltip
            ></px-button>
            <px-button v-if="scope.row.creatorId != userId" link>-</px-button>
          </template>
        </px-table-column>
        <template #empty>
          <px-empty :image-size="150" />
        </template>
      </px-table>
    </px-dialog>
    <px-dialog v-model="setTimeOpen" draggable clickHideContent width="1486" :close-on-click-modal="false" title="仪表日程" align-center>
      <px-date-picker
        v-model="queryEqpDetailTime"
        type="datetimerange"
        range-separator="-"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        placeholder="请选择"
        format="YYYY-MM-DD"
        value-format="YYYY-MM-DD"
      />
      <px-button style="margin-top: -6px; margin-left: 16px" type="primary" icon="" @click="handleQueryPlan()">查询</px-button>
      <px-button style="margin-top: -6px" icon="" @click="resetQueryplan()">重置</px-button>
      <px-table style="margin-top: 20px" :data="EqpDetailList" height="480px" border>
        <px-table-column label="日期" width="150" prop="date">
          <template #default="scope">
            <span>{{ scope.row.date }}</span>
          </template>
        </px-table-column>
        <px-table-column label="0点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[0].scheduledId == null && scope.row.scheduleId[0].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[0], 0, scope.$index)"
              >{{ scope.row.scheduleId[0].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[0].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[0].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[0], 0, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="1点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[1].scheduledId == null && scope.row.scheduleId[1].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[1], 1, scope.$index)"
              >{{ scope.row.scheduleId[1].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[1].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[1].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[1], 1, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="2点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[2].scheduledId == null && scope.row.scheduleId[2].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[2], 2, scope.$index)"
              >{{ scope.row.scheduleId[2].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[2].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[2].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[2], 2, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="3点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[3].scheduledId == null && scope.row.scheduleId[3].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[3], 3, scope.$index)"
              >{{ scope.row.scheduleId[3].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[3].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[3].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[3], 3, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="4点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[4].scheduledId == null && scope.row.scheduleId[4].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[4], 4, scope.$index)"
              >{{ scope.row.scheduleId[4].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[4].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[4].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[4], 4, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="5点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[5].scheduledId == null && scope.row.scheduleId[5].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[5], 5, scope.$index)"
              >{{ scope.row.scheduleId[5].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[5].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[5].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[5], 5, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="6点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[6].scheduledId == null && scope.row.scheduleId[6].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[6], 6, scope.$index)"
              >{{ scope.row.scheduleId[6].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[6].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[6].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[6], 6, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="7点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[7].scheduledId == null && scope.row.scheduleId[7].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[7], 7, scope.$index)"
              >{{ scope.row.scheduleId[7].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[7].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[7].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[7], 7, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="8点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[8].scheduledId == null && scope.row.scheduleId[8].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[8], 8, scope.$index)"
              >{{ scope.row.scheduleId[8].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[8].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[8].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[8], 8, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="9点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[9].scheduledId == null && scope.row.scheduleId[9].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[9], 9, scope.$index)"
              >{{ scope.row.scheduleId[9].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[9].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[9].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[9], 9, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="10点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[10].scheduledId == null && scope.row.scheduleId[10].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[10], 10, scope.$index)"
              >{{ scope.row.scheduleId[10].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[10].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[10].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[10], 10, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="11点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[11].scheduledId == null && scope.row.scheduleId[11].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[11], 11, scope.$index)"
              >{{ scope.row.scheduleId[11].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[11].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[11].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[11], 11, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="12点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[12].scheduledId == null && scope.row.scheduleId[12].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[12], 12, scope.$index)"
              >{{ scope.row.scheduleId[12].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[12].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[12].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[12], 12, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="13点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[13].scheduledId == null && scope.row.scheduleId[13].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[13], 13, scope.$index)"
              >{{ scope.row.scheduleId[13].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[13].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[13].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[13], 13, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="14点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[14].scheduledId == null && scope.row.scheduleId[14].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[14], 14, scope.$index)"
              >{{ scope.row.scheduleId[14].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[14].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[14].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[14], 14, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="15点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[15].scheduledId == null && scope.row.scheduleId[15].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[15], 15, scope.$index)"
              >{{ scope.row.scheduleId[15].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[15].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[15].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[15], 15, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="16点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[16].scheduledId == null && scope.row.scheduleId[16].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[16], 16, scope.$index)"
              >{{ scope.row.scheduleId[16].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[16].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[16].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[16], 16, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="17点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[17].scheduledId == null && scope.row.scheduleId[17].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[17], 17, scope.$index)"
              >{{ scope.row.scheduleId[17].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[17].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[17].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[17], 17, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="18点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[18].scheduledId == null && scope.row.scheduleId[18].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[18], 18, scope.$index)"
              >{{ scope.row.scheduleId[18].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[18].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[18].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[18], 18, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="19点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[19].scheduledId == null && scope.row.scheduleId[19].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[19], 19, scope.$index)"
              >{{ scope.row.scheduleId[19].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[19].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[19].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[19], 19, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="20点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[20].scheduledId == null && scope.row.scheduleId[20].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[20], 20, scope.$index)"
              >{{ scope.row.scheduleId[20].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[20].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[20].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[20], 20, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="21点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[21].scheduledId == null && scope.row.scheduleId[21].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[21], 21, scope.$index)"
              >{{ scope.row.scheduleId[21].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[21].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[21].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[21], 21, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="22点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[22].scheduledId == null && scope.row.scheduleId[22].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[22], 22, scope.$index)"
              >{{ scope.row.scheduleId[22].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[22].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[22].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[22], 22, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="23点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[23].scheduledId == null && scope.row.scheduleId[23].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[23], 23, scope.$index)"
              >{{ scope.row.scheduleId[23].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[23].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[23].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[23], 23, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>

        <template #empty>
          <px-empty :image-size="150" />
        </template>
      </px-table>
      <template #footer>
        <span class="dialog-footer">
          <px-button @click="addcancel()">取消</px-button>
          <!-- <px-button type="primary" plain @click="clearbtn()">清空</px-button> -->
          <px-button v-if="buttonTitle == '新增'" :disabled="setTimeList.length < 2" type="primary" @click="addbtn()"> 添加 </px-button>
          <px-button v-else type="primary" :disabled="setTimeList.length < 2" @click="savebtn()"> 保存 </px-button>
        </span>
      </template>
    </px-dialog>
    <!-- 新增计划 -->
    <px-dialog v-model="setPlanOpen" draggable clickHideContent width="1486" :close-on-click-modal="false" title="仪表日程" align-center>
      <p style="margin-bottom: 16px; font-size: 14px; color: black">
        <span>系统</span>
        <px-tree-select
          v-model="PlansystemCode"
          clearable
          style="width: 300px; margin-left: 16px"
          placeholder="请选择设备系统（树状图）"
          :props="defaultProps"
          :data="systemList"
          filterable
          @node-click="nodeClick"
        />
        <span v-if="diyplan" style="margin-left: 16px">仪表编号/名称</span>
        <px-select
          v-if="diyplan"
          v-model="PlaneqpeqpCode"
          style="margin-left: 16px"
          placeholder="请选择"
          clearable
          allow-create
          filterable
          @change="seteqpName"
        >
          <px-option v-for="item in eqpList" :key="item.id" :label="item.eqpName" :value="item.eqpId" />
        </px-select>
        <span v-if="!diyplan" style="margin-left: 16px">仪表名称</span>
        <px-input v-if="!diyplan" v-model="eqpName" style="width: 200px; margin-left: 16px" placeholder="请输入" clearable />
        <span v-if="!diyplan" style="margin-left: 16px">仪表编号</span>
        <px-input
          v-if="!diyplan"
          v-model="PlaneqpeqpCode"
          style="width: 200px; margin-left: 16px"
          placeholder="请输入"
          clearable
          @input="geteqpName"
        />
        <px-button v-if="diyplan" style="margin-left: 16px" type="primary" plain @click="setdiyplan">自定义仪表</px-button>
        <px-button v-if="!diyplan" style="margin-left: 16px" type="primary" plain @click="setdiyplan">选择仪表</px-button>
      </p>
      <px-date-picker
        v-model="queryEqpDetailTime"
        type="datetimerange"
        range-separator="-"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        placeholder="请选择"
        format="YYYY-MM-DD"
        value-format="YYYY-MM-DD"
      />
      <px-button style="margin-top: -6px; margin-left: 16px" type="primary" icon="" @click="handleQueryPlan2()">查询</px-button>
      <!-- <px-button style="margin-top: -6px" icon="" @click="resetQueryplan2()">重置</px-button> -->
      <px-table style="margin-top: 20px" :data="EqpDetailList" height="480px" border>
        <px-table-column label="日期" width="150" prop="date">
          <template #default="scope">
            <span>{{ scope.row.date }}</span>
          </template>
        </px-table-column>
        <px-table-column label="0点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[0].scheduledId == null && scope.row.scheduleId[0].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[0], 0, scope.$index)"
              >{{ scope.row.scheduleId[0].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[0].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[0].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[0], 0, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="1点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[1].scheduledId == null && scope.row.scheduleId[1].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[1], 1, scope.$index)"
              >{{ scope.row.scheduleId[1].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[1].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[1].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[1], 1, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="2点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[2].scheduledId == null && scope.row.scheduleId[2].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[2], 2, scope.$index)"
              >{{ scope.row.scheduleId[2].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[2].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[2].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[2], 2, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="3点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[3].scheduledId == null && scope.row.scheduleId[3].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[3], 3, scope.$index)"
              >{{ scope.row.scheduleId[3].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[3].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[3].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[3], 3, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="4点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[4].scheduledId == null && scope.row.scheduleId[4].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[4], 4, scope.$index)"
              >{{ scope.row.scheduleId[4].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[4].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[4].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[4], 4, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="5点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[5].scheduledId == null && scope.row.scheduleId[5].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[5], 5, scope.$index)"
              >{{ scope.row.scheduleId[5].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[5].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[5].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[5], 5, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="6点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[6].scheduledId == null && scope.row.scheduleId[6].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[6], 6, scope.$index)"
              >{{ scope.row.scheduleId[6].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[6].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[6].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[6], 6, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="7点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[7].scheduledId == null && scope.row.scheduleId[7].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[7], 7, scope.$index)"
              >{{ scope.row.scheduleId[7].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[7].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[7].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[7], 7, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="8点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[8].scheduledId == null && scope.row.scheduleId[8].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[8], 8, scope.$index)"
              >{{ scope.row.scheduleId[8].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[8].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[8].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[8], 8, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="9点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[9].scheduledId == null && scope.row.scheduleId[9].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[9], 9, scope.$index)"
              >{{ scope.row.scheduleId[9].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[9].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[9].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[9], 9, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="10点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[10].scheduledId == null && scope.row.scheduleId[10].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[10], 10, scope.$index)"
              >{{ scope.row.scheduleId[10].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[10].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[10].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[10], 10, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="11点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[11].scheduledId == null && scope.row.scheduleId[11].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[11], 11, scope.$index)"
              >{{ scope.row.scheduleId[11].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[11].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[11].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[11], 11, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="12点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[12].scheduledId == null && scope.row.scheduleId[12].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[12], 12, scope.$index)"
              >{{ scope.row.scheduleId[12].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[12].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[12].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[12], 12, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="13点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[13].scheduledId == null && scope.row.scheduleId[13].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[13], 13, scope.$index)"
              >{{ scope.row.scheduleId[13].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[13].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[13].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[13], 13, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="14点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[14].scheduledId == null && scope.row.scheduleId[14].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[14], 14, scope.$index)"
              >{{ scope.row.scheduleId[14].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[14].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[14].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[14], 14, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="15点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[15].scheduledId == null && scope.row.scheduleId[15].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[15], 15, scope.$index)"
              >{{ scope.row.scheduleId[15].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[15].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[15].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[15], 15, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="16点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[16].scheduledId == null && scope.row.scheduleId[16].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[16], 16, scope.$index)"
              >{{ scope.row.scheduleId[16].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[16].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[16].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[16], 16, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="17点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[17].scheduledId == null && scope.row.scheduleId[17].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[17], 17, scope.$index)"
              >{{ scope.row.scheduleId[17].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[17].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[17].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[17], 17, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="18点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[18].scheduledId == null && scope.row.scheduleId[18].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[18], 18, scope.$index)"
              >{{ scope.row.scheduleId[18].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[18].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[18].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[18], 18, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="19点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[19].scheduledId == null && scope.row.scheduleId[19].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[19], 19, scope.$index)"
              >{{ scope.row.scheduleId[19].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[19].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[19].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[19], 19, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="20点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[20].scheduledId == null && scope.row.scheduleId[20].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[20], 20, scope.$index)"
              >{{ scope.row.scheduleId[20].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[20].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[20].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[20], 20, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="21点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[21].scheduledId == null && scope.row.scheduleId[21].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[21], 21, scope.$index)"
              >{{ scope.row.scheduleId[21].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[21].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[21].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[21], 21, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="22点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[22].scheduledId == null && scope.row.scheduleId[22].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[22], 22, scope.$index)"
              >{{ scope.row.scheduleId[22].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[22].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[22].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[22], 22, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>
        <px-table-column label="23点" width="53" prop="startTime">
          <template #default="scope">
            <span
              v-if="scope.row.scheduleId[23].scheduledId == null && scope.row.scheduleId[23].planName == null"
              class="spanhover"
              @click="addTimeList(scope.row, scope.row.scheduleId[23], 23, scope.$index)"
              >{{ scope.row.scheduleId[23].scheduledId }}</span
            >
            <span v-else-if="scope.row.scheduleId[23].scheduledId == 'true'" class="spandisabled2" />
            <px-tooltip v-else class="box-item" effect="dark" :content="getplantext(scope.row.scheduleId[23].scheduledId)" placement="top">
              <span class="spandisabled" @click="addTimeList(scope.row, scope.row.scheduleId[23], 23, scope.$index)" />
            </px-tooltip>
          </template>
        </px-table-column>

        <template #empty>
          <px-empty :image-size="150" />
        </template>
      </px-table>
      <template #footer>
        <span class="dialog-footer">
          <px-button @click="addcancel()">取消</px-button>
          <!-- <px-button type="primary" plain @click="clearbtn()">清空</px-button> -->
          <px-button :disabled="setTimeList.length < 2" type="primary" @click="addbtn2()"> 添加 </px-button>
        </span>
      </template>
    </px-dialog>
  </div>
</template>

<script setup name="Dict" lang="ts">
// import useDictStore from '@/store/modules/dict'
defineOptions({
  name: "SystemDataDict"
});
// import { router } from "@/router";
import { ArrowLeft } from "@px-ui/icons-vue";
import { useRoute } from "vue-router";
import { PxMessage, PxMessageBox } from "px-ui";
import { getCurrentInstance, ref, toRefs, reactive, onMounted } from "vue";
import { getToken } from "@/utils/auth";
import PhotoUpload from "@/components/Upload/PhotoUpload.vue";
import FileUpload from "@/components/Upload/FileUpload.vue";
import { queryChildByTypeCodeAndItemValue, liquidFileDelete } from "@/api/waterClass";
import {
  generalqueryDetail,
  precursorChemicalPurchasePermitqueryListPage,
  precursorChemicalPurchasePermitadd,
  precursorChemicalPurchasePermitdelete,
  precursorChemicalPurchasePermitupdate,
  precursorChemicalPurchasePermitqueryDetail,
  precursorChemicalPurchasePermitqueryChemicalList
} from "@/api/chemicals";
import {
  schedulequeryEqpDetail,
  schedulequeryLatestScheduleListPage,
  scheduleadd,
  scheduledelete,
  scheduleupdate,
  schedulequeryEqpScheduleList,
  schedulequeryScheduleEqpName,
  schedulequeryScheduleEqpCode,
  schedulequeryScheduleListPageV2,
  schedulequeryPreCustomizeEqpInfo
} from "@/api/verifymanage";
import { userlistPage } from "@/api/waterQualityDetection";
import { querySystemSelect } from "@/api/equip/archive";
import { queryEquipLedger } from "@/api/equip/archive";

const PlaneqpeqpCode = ref("");
const PlansystemCode = ref("");
const geteqpName = () => {
  schedulequeryPreCustomizeEqpInfo({
    eqpCode: PlaneqpeqpCode.value
  }).then(res => {
    console.log(res);
    if (res != null) {
      eqpName.value = res.eqpName;
      PlansystemCode.value = res.systemCode;
      systemName.value = res.systemName;
    }
  });
};
const defaultProps = {
  children: "children",
  label: "name",
  value: "code"
};
const jibenxinxiFlg = ref(true);
const defaultTime: [Date, Date] = [new Date(2000, 1, 1, 0, 0, 1), new Date(2000, 1, 1, 23, 59, 59)];
const changeresponsiblePerson = val => {
  userList.value.forEach(item => {
    if (item.value == val) {
      console.log(item);
      equipdata.value.responsiblePerson = item.label;
    }
  });
};
const nodeClick = (e1emData, nodeData) => {
  console.log(e1emData, nodeData);
  // selectTree.value = e1emData;
  systemName.value = e1emData.name;
  queryEquipLedger({
    pageNum: 1,
    pageSize: 9999,
    className: "WATER",
    typeId: "",
    modelId: "",
    categoryId: 35,
    systemCode: e1emData.code,
    systemCodes: [e1emData.code]
  }).then(res => {
    console.log(res);
    eqpList.value = res.data;
  });
};
const changechemicalCode = val => {
  querychemicalList.value.forEach(item => {
    if (item.chemicalCode == val) {
      console.log(item);
      equipdata.value.chemical = item.chemical;
    }
  });
};

const setqingdanFlg = () => {
  jibenxinxiFlg.value = !jibenxinxiFlg.value;
};
const jiqicanshuFlg = ref(true);
const setjiqicanshuFlg = () => {
  jiqicanshuFlg.value = !jiqicanshuFlg.value;
};
const shebeitaizhangFlg = ref(true);
const setshebeitaizhangFlg = () => {
  shebeitaizhangFlg.value = !shebeitaizhangFlg.value;
};
const moxingshezhiFlg = ref(true);
const setmoxingshezhiFlg = () => {
  moxingshezhiFlg.value = !moxingshezhiFlg.value;
};

const setreceiveCompanyCode = val => {
  let setvalue = null;
  setvalue = liquidList.value.find(option => option.itemValue == val);
  if (setvalue && setvalue?.itemDesc != "") {
    queryParams.value.receiveCompanyCode = JSON.parse(setvalue.itemDesc).receiveCompanyCode;
  } else {
    queryParams.value.receiveCompanyCode = "";
  }
  //console.log(setvalue);
};

const setAddreceiveCompanyCode = val => {
  let setvalue = null;
  setvalue = liquidList.value.find(option => option.itemValue == val);
  if (setvalue && setvalue.itemDesc != "") {
    equipdata.value.receiveCompanyCode = JSON.parse(setvalue.itemDesc).receiveCompanyCode;
  } else {
    // equipdata.value.receiveCompanyCode = "";
  }
  //console.log(setvalue);
};
const route = useRoute();
function formatDate(date) {
  const year = date.getFullYear();
  const month = (date.getMonth() + 1).toString().padStart(2, "0");
  const day = date.getDate().toString().padStart(2, "0");
  const h = date.getHours().toString().padStart(2, "0");
  const m = date.getMinutes().toString().padStart(2, "0");
  const s = date.getSeconds().toString().padStart(2, "0");
  return `${year}-${month}-${day} ${h}:${m}:${s}`;
}
onMounted(() => {
  if (route.query.equipmentId) {
    handleDetail(route.query.equipmentId);
  }
  getThisWeekTime();
  const userInfo = localStorage.getItem("userInfo");
  userId.value = JSON.parse(userInfo).userId;
  console.log(userId.value);
  const end = new Date();
  end.setTime(end.getTime());
  const start = new Date();
  const start2 = new Date();
  start.setTime(start.getTime() + 3600 * 1000 * 24 * 10);
  dateRange.value = [formatDate(end), formatDate(start)];
  getList();
});
const setPlanOpen = ref(false);
const { proxy }: any = getCurrentInstance();
const typeList = ref([]);
const detailruleFormRef = ref();
const progressVisible = ref(false);
const open = ref(false);
const equipopen = ref(false);
const equipopenDetail = ref(false);
const fromdisable = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const typeIdloading = ref(false);
const total = ref(0);
const progressPercent = ref(0);
const title = ref("");
const dateRange = ref([]);
const setTimeOpen = ref(false);
const diyplan = ref(true);
const setdiyplan = () => {
  diyplan.value = !diyplan.value;
};
// 图片是否上传完，是否可以保存
const savePhotoStatus1 = val => {
  console.log(val);
  photoStatusFlag.value = val;
};
const savePhotoStatus2 = val => {
  photoStatusFlag.value = val;
};
const savePhotoStatus3 = val => {
  photoStatusFlag.value = val;
};
const savePhotoStatus4 = val => {
  photoStatusFlag.value = val;
};
// 文件是否上传完，是否可以保存
const saveFileStatus = val => {
  fileStatusFlag.value = val;
};

const waterstatusList = [
  {
    value: "VALID",
    name: "全部"
  },
  {
    value: "INVALID",
    name: "已删除"
  }
];
const limitTimesTypeList = [
  {
    itemName: "单次有效",
    itemValue: "SINGLE"
  },
  {
    itemName: "多次有效",
    itemValue: "MANY"
  }
];
const buttonTitle = ref("");
const data = reactive({
  liquidList: [],
  storeList: [],
  sellList: [],
  transportCompanyList: [],
  receiveCompanyList: [],
  typeIdList: [],
  categoryList: [],
  equipmentTypeList: [],
  positionList: [],
  equipmentDeptList: [],
  modelIdList: [],
  form: {},
  photoStatusFlag: false,
  fileStatusFlag: false,
  equipdata: {
    id: "",
    permitOutNumber: "",
    chemicalCode: "",
    chemical: "",
    purchaseUnit: "",
    totalQuantity: "",
    remainQuantity: "",
    effectiveDateFrom: "",
    effectiveDateTo: "",
    limitTimesType: "",
    salesCompany: "",
    responsiblePersonId: "",
    responsiblePerson: "",
    permitAttachment: [],
    legalAttachment: [],
    timevalue: [],
    updateTime: "",
    permitNumber: ""
  },
  queryParams: {
    orderByColumn: "",
    isAsc: "",
    systemCode: "",
    eqpName: "",
    eqpCode: "",
    orderBy: "",
    startTime: "",
    endTime: "",
    pageNum: 1,
    pageSize: 10
  },
  rules: {
    permitOutNumber: [{ required: true, message: "购买证编码不能为空", trigger: "blur" }],
    chemicalCode: [{ required: true, message: "化学品名称不能为空", trigger: "blur" }],
    salesCompany: [{ required: true, message: "销售单位不能为空", trigger: "blur" }],
    totalQuantity: [{ required: true, message: "可购入数量不能为空", trigger: "blur" }],
    timevalue: [{ required: true, message: "有效时间不能为空", trigger: "change" }],
    purchaseUnit: [{ required: true, message: "单位不能为空", trigger: "change" }],
    limitTimesType: [{ required: true, message: "限次类型为空", trigger: "change" }],
    responsiblePersonId: [{ required: true, message: "办理人不能为空", trigger: "change" }]
  },
  headers: {
    Authorization: "Bearer " + getToken().accessToken || ""
  },
  moduleName: "",
  dialogImageUrl: "",
  imageVisible: false,
  chemicalList: [],
  querychemicalList: [],
  unitList: [
    {
      id: 1808,
      typeId: "WTTS",
      itemName: "千克",
      itemValue: "KG",
      itemDesc: "",
      parentId: "CHEMICAL_UNIT",
      level: 2,
      itemSort: 0,
      status: "VALID",
      remark: "",
      createTime: "2024-09-03 14:48:03",
      updateTime: "2024-09-03 14:48:03",
      children: null
    }
  ],
  userList: [],
  eqpList: [],
  systemList: [],
  dataplanList: [],
  appearanceSelect: [],
  setTimeList: [],
  setTimeListindex1: "",
  setTimeListindex2: "",
  setrow: {},
  queryEqpDetailTime: [],
  EqpDetailList: [],
  EqpDetailjobList: {},
  scheduleupdateid: "",
  scheduleupdateupdateTime: "",
  userId: "",
  setTimeListvalue: [],
  colIndexList: [],
  indexValList: [],
  EqpNameList: [],
  EqpCodeList: []
});

const {
  EqpNameList,
  EqpCodeList,
  setTimeListvalue,
  colIndexList,
  indexValList,
  userId,
  scheduleupdateupdateTime,
  scheduleupdateid,
  setrow,
  setTimeListindex1,
  setTimeListindex2,
  EqpDetailjobList,
  EqpDetailList,
  queryEqpDetailTime,
  setTimeList,
  appearanceSelect,
  dataplanList,
  eqpList,
  systemList,
  liquidList,
  transportCompanyList,
  receiveCompanyList,
  queryParams,
  form,
  rules,
  equipdata,
  typeIdList,
  equipmentTypeList,
  modelIdList,
  dialogImageUrl,
  imageVisible,
  storeList,
  sellList,
  photoStatusFlag,
  fileStatusFlag,
  chemicalList,
  unitList,
  userList,
  querychemicalList
} = toRefs(data);
const handleRemove = file => {
  equipdata.value.attachment = equipdata.value.attachment.filter(item => item !== file);
  let parmas = {
    fileId: file.fileId ? file.fileId : file?.response?.data?.fileId,
    ledgerCode: equipdata.value.ledgerCode
  };
  liquidFileDelete(parmas).then((response: any) => {
    // //console.log(response);
    PxMessage({
      type: "success",
      message: "删除成功"
    });
  });
};
const checkTime = () => {
  if (equipdata.value.manufactureDate && equipdata.value.warrantyEndDate) {
    if (equipdata.value.manufactureDate > equipdata.value.warrantyEndDate) {
      PxMessage({
        message: "开始时间不能大于结束时间",
        type: "error"
      });
    }
  }
};
const geteqpList = () => {
  schedulequeryScheduleEqpName({
    systemCode: queryParams.value.systemCode,
    requestId: ""
  }).then(res => {
    console.log(res);
    EqpNameList.value = res;
  });
  schedulequeryScheduleEqpCode({
    systemCode: queryParams.value.systemCode,
    requestId: ""
  }).then(res => {
    console.log(res);
    EqpCodeList.value = res;
  });
};
const getqueryCategoryList = () => {
  queryEquipLedger({
    pageNum: 1,
    pageSize: 9999,
    className: "WATER",
    typeId: "",
    modelId: "",
    categoryId: 35
  }).then(res => {
    console.log(res);
    eqpList.value = res.data;
  });
  querySystemSelect({ factoryArea: "", className: "WATER" }).then(res => {
    // console.log(res[0].children);
    systemList.value = res[0].children.filter((item, index) => item.name == "纯水生产线系统" || item.name == "纯水验证线系统");
  });
  geteqpList();
};
getqueryCategoryList();

function getList() {
  loading.value = true;
  if (dateRange.value != null) {
    queryParams.value.startTime = dateRange.value[0];
    queryParams.value.endTime = dateRange.value[1];
  } else {
    queryParams.value.startTime = "";
    queryParams.value.endTime = "";
  }
  schedulequeryScheduleListPageV2(queryParams.value).then((response: any) => {
    typeList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}
const handleAddPlan = () => {
  setPlanOpen.value = true;
  diyplan.value = true;
  appearanceSelect.value = [];
  EqpDetailList.value = [];
  EqpDetailjobList.value = [];
  PlaneqpeqpCode.value = "";
  eqpName.value = "";
  PlansystemCode.value = "";
  setTimeList.value = [];
  setTimeListvalue.value = [];
  colIndexList.value = [];
  indexValList.value = [];
};
const getBlock = val => {
  console.log(val);
};
/** 取消按钮 */
function cancel() {
  equipopen.value = false;
  subLoading.value = false;
}
function equipopenDetailcancel() {
  equipopenDetail.value = false;
  subLoading.value = false;
}
/** 表单重置 */
function reset() {
  form.value = {
    id: undefined,
    dictionaryName: undefined,
    dictionaryType: undefined,
    status: "VALID",
    remarks: undefined
  };
  proxy.resetForm("dictRef");
}
/** 搜索按钮操作 */
function handleQuery(type) {
  if (type == "search") {
    queryParams.value.pageNum = 1;
  }
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  queryParams.value = {
    pageNum: queryParams.value.pageNum,
    pageSize: queryParams.value.pageSize,
    startTime: "",
    endTime: "",
    orderByColumn: "",
    isAsc: "",
    systemCode: "",
    eqpName: "",
    eqpCode: "",
    orderBy: ""
  };
  const end = new Date();
  end.setTime(end.getTime());
  const start = new Date();
  const start2 = new Date();
  start.setTime(start.getTime() + 3600 * 1000 * 24 * 10);
  dateRange.value = [formatDate(end), formatDate(start)];
  // querychemicalList.value = [];
  handleQuery("reset");
}
/** 新增按钮操作 */
function handleAdd() {
  buttonTitle.value = "新增";
  setTimeOpen.value = true;
  schedulequeryEqpDetail({
    eqpCode: appearanceSelect.value.eqpCode,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
  setTimeList.value = [];
  setTimeListvalue.value = [];
  colIndexList.value = [];
  indexValList.value = [];
}
const addcancel = () => {
  setPlanOpen.value = false;
  setTimeOpen.value = false;
  setTimeList.value = [];
  setTimeListvalue.value = [];
  colIndexList.value = [];
  indexValList.value = [];
};
const donverDateTime = datestr => {
  const year = datestr.slice(0, 4);
  const month = datestr.slice(5, 7);
  const day = datestr.slice(8, 10);
  // console.log(`${year}-${month}-${day}`);
  return `${year}-${month}-${day}`;
};
const gettime = date => {
  if (date == "0点") {
    return "00:00";
  }
  if (date == "1点") {
    return "01:00";
  }
  if (date == "2点") {
    return "02:00";
  }
  if (date == "3点") {
    return "03:00";
  }
  if (date == "4点") {
    return "04:00";
  }
  if (date == "5点") {
    return "05:00";
  }
  if (date == "6点") {
    return "06:00";
  }
  if (date == "7点") {
    return "07:00";
  }
  if (date == "8点") {
    return "08:00";
  }
  if (date == "9点") {
    return "09:00";
  }
  if (date == "10点") {
    return "10:00";
  }
  if (date == "11点") {
    return "11:00";
  }
  if (date == "12点") {
    return "12:00";
  }
  if (date == "13点") {
    return "13:00";
  }
  if (date == "14点") {
    return "14:00";
  }
  if (date == "15点") {
    return "15:00";
  }
  if (date == "16点") {
    return "16:00";
  }
  if (date == "17点") {
    return "17:00";
  }
  if (date == "18点") {
    return "18:00";
  }
  if (date == "19点") {
    return "19:00";
  }
  if (date == "20点") {
    return "20:00";
  }
  if (date == "21点") {
    return "21:00";
  }
  if (date == "22点") {
    return "22:00";
  }
  if (date == "23点") {
    return "23:00";
  }
};
const systemName = ref("");
const addbtn = () => {
  // console.log(`${donverDateTime(setrow.value.date)} ${gettime(setTimeList.value[0].time)}`);
  scheduleadd({
    eqpCode: setPlanOpen.value ? PlaneqpeqpCode.value : appearanceSelect.value.eqpCode,
    startTime: `${donverDateTime(setTimeListvalue.value[0].date)} ${gettime(setTimeList.value[0].time)}`,
    endTime: `${donverDateTime(setTimeListvalue.value[1].date)} ${gettime(setTimeList.value[1].time)}`,
    creatorName: `${JSON.parse(localStorage.getItem("userInfo")).username}-${JSON.parse(localStorage.getItem("userInfo")).realName}`,
    customizeEqp: diyplan.value ? "N" : "Y",
    eqpName: eqpName.value,
    systemCode: PlansystemCode.value,
    systemName: systemName.value
  })
    .then(res => {
      PxMessage({
        message: "添加成功",
        type: "success"
      });
      setTimeOpen.value = false;
      handleDetail(appearanceSelect.value);
      getList();
    })
    .catch(() => {
      handleAdd();
      getList();
    });
};
const addbtn2 = () => {
  // console.log(`${donverDateTime(setrow.value.date)} ${gettime(setTimeList.value[0].time)}`);
  scheduleadd({
    eqpCode: setPlanOpen.value ? PlaneqpeqpCode.value : appearanceSelect.value.eqpCode,
    startTime: `${donverDateTime(setTimeListvalue.value[0].date)} ${gettime(setTimeList.value[0].time)}`,
    endTime: `${donverDateTime(setTimeListvalue.value[1].date)} ${gettime(setTimeList.value[1].time)}`,
    creatorName: `${JSON.parse(localStorage.getItem("userInfo")).username}-${JSON.parse(localStorage.getItem("userInfo")).realName}`,
    customizeEqp: diyplan.value ? "N" : "Y",
    eqpName: eqpName.value,
    systemCode: PlansystemCode.value,
    systemName: systemName.value
  })
    .then(res => {
      PxMessage({
        message: "添加成功",
        type: "success"
      });
      setPlanOpen.value = false;
      getList();
    })
    .catch(() => {
      getList();
    });
};
const savebtn = () => {
  console.log(setTimeList.value);
  scheduleupdate({
    id: scheduleupdateid.value,
    updateTime: scheduleupdateupdateTime.value,
    eqpCode: appearanceSelect.value.eqpCode,
    startTime: `${donverDateTime(setTimeListvalue.value[0].date)} ${gettime(setTimeList.value[0].time)}`,
    endTime: `${donverDateTime(setTimeListvalue.value[1].date)} ${gettime(setTimeList.value[1].time)}`
  })
    .then(res => {
      PxMessage({
        message: "修改成功",
        type: "success"
      });
      setTimeOpen.value = false;
      handleDetail(appearanceSelect.value);
      setTimeList.value = [];
    })
    .catch(() => {
      handleAdd();
      setTimeList.value = [];
    });
};
const getplantext = idval => {
  // console.log(EqpDetailjobList.value[idval].planName);
  return EqpDetailjobList.value[idval].planName ? EqpDetailjobList.value[idval].planName : EqpDetailjobList.value[idval].eqpCode;
};
const handleQueryPlan = () => {
  schedulequeryEqpDetail({
    eqpCode: appearanceSelect.value.eqpCode,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
};

const handleQueryPlan2 = () => {
  console.log(PlaneqpeqpCode.value);
  schedulequeryEqpDetail({
    eqpCode: PlaneqpeqpCode.value,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
};
const resetQueryplan = () => {
  getThisWeekTime();
  schedulequeryEqpDetail({
    eqpCode: appearanceSelect.value.eqpCode,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
};
const resetQueryplan2 = () => {
  getThisWeekTime();
  schedulequeryEqpDetail({
    eqpCode: PlaneqpeqpCode.value,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
};
const handleDetail = async val => {
  appearanceSelect.value = val;
  equipopen.value = true;
  diyplan.value = val.customizeEqp == "N" ? true : false;
  console.log(diyplan.value);
  eqpName.value = val.eqpName;
  PlaneqpeqpCode.value = val.PlaneqpeqpCode;
  schedulequeryEqpScheduleList({
    pageNum: 1,
    pageSize: 99,
    eqpCode: val.eqpCode,
    eqpName: val.eqpName
  }).then(res => {
    dataplanList.value = res.data;
  });
};
const seteqpName = val => {
  console.log(val);
};
const getThisWeekTime = () => {
  let today = new Date();
  let currentDay = today.getDay();
  let starDate = new Date(today.getTime() - (currentDay - 1) * 86400000);
  let endDate = new Date(starDate.getTime() + 6 * 86400000);
  let startDateString = starDate.toISOString().split("T")[0];
  let endDateString = endDate.toISOString().split("T")[0];
  queryEqpDetailTime.value = [startDateString, endDateString];
  console.log(startDateString, endDateString);
};

const handleEditor = val => {
  setTimeList.value = [];
  setTimeListvalue.value = [];
  colIndexList.value = [];
  indexValList.value = [];
  console.log(val);
  buttonTitle.value = "编辑";
  scheduleupdateid.value = val.id;
  scheduleupdateupdateTime.value = val.updateTime;
  setTimeOpen.value = true;
  schedulequeryEqpDetail({
    eqpCode: appearanceSelect.value.eqpCode,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
  setTimeList.value = [];
};
const eqpName = ref("");
const clearbtn = () => {
  schedulequeryEqpDetail({
    eqpCode: setPlanOpen.value ? PlaneqpeqpCode.value : appearanceSelect.value.eqpCode,
    startTime: queryEqpDetailTime.value[0],
    endTime: queryEqpDetailTime.value[1]
  }).then(res => {
    console.log(res);
    EqpDetailList.value = res.data;
    EqpDetailjobList.value = res.scheduleIdMap;
  });
  setTimeList.value = [];
  setTimeListvalue.value = [];
  colIndexList.value = [];
  indexValList.value = [];
};
/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
// 新的图片列表
const changePhotoList1 = val => {
  equipdata.value.permitAttachment = val;
  console.log(val);
};
const addTimeList = (rowVal, scheduleIdVal, indexVal, colIndex) => {
  if (setTimeList.value.length > 1) {
    console.log("清空");
    clearbtn();
    return false;
  }
  if (setTimeList.value.length < 1) {
    scheduleIdVal.scheduledId = "true";
    setTimeList.value.push(scheduleIdVal);
    setTimeListindex1.value = indexVal;
    setrow.value = rowVal;
    setTimeListvalue.value.push(rowVal);
    colIndexList.value.push(colIndex);
    indexValList.value.push(indexVal);
    console.log(rowVal, scheduleIdVal, indexVal, colIndex);
  } else {
    if (setrow.value.date == rowVal.date) {
      if (Number(indexVal) < Number(setTimeListindex1.value)) {
        setTimeList.value.unshift(scheduleIdVal);
        setTimeListvalue.value.unshift(rowVal);
      } else {
        setTimeList.value.push(scheduleIdVal);
        setTimeListvalue.value.push(rowVal);
      }
      console.log(setTimeList.value);
      rowVal.scheduleId.forEach((item, index) => {
        if (indexVal > setTimeListindex1.value) {
          if (Number(setTimeListindex1.value) <= Number(index) && Number(index) <= Number(indexVal)) {
            item.scheduledId = "true";
          }
        } else {
          if (Number(indexVal) <= Number(index) && Number(index) <= Number(setTimeListindex1.value)) {
            item.scheduledId = "true";
          }
        }

        // console.log(index, indexVal);
      });
    } else {
      if (chineseDateToISO8601(rowVal.date) < chineseDateToISO8601(setrow.value.date)) {
        setTimeList.value.unshift(scheduleIdVal);
        setTimeListvalue.value.unshift(rowVal);
        colIndexList.value.unshift(colIndex);
        indexValList.value.unshift(indexVal);
        console.log(setTimeListvalue.value, setTimeList.value, colIndexList.value, indexValList.value);
        EqpDetailList.value.forEach((itemvalue, index) => {
          if (index == colIndexList.value[0]) {
            itemvalue.scheduleId.forEach((item, index) => {
              if (index >= indexValList.value[0]) {
                item.scheduledId = "true";
              }
            });
          }
          if (index == colIndexList.value[1]) {
            itemvalue.scheduleId.forEach((item, index) => {
              if (index <= indexValList.value[1]) {
                item.scheduledId = "true";
              }
            });
          }
          if (index > Number(colIndexList.value[0]) && index < Number(colIndexList.value[1])) {
            itemvalue.scheduleId.forEach((item, index) => {
              item.scheduledId = "true";
            });
          }
        });
      } else {
        setTimeList.value.push(scheduleIdVal);
        setTimeListvalue.value.push(rowVal);
        colIndexList.value.push(colIndex);
        indexValList.value.push(indexVal);
        console.log(setTimeListvalue.value, setTimeList.value, colIndexList.value, indexValList.value);
        EqpDetailList.value.forEach((itemvalue, index) => {
          if (index == colIndexList.value[0]) {
            itemvalue.scheduleId.forEach((item, index) => {
              if (index >= indexValList.value[0]) {
                item.scheduledId = "true";
              }
            });
          }
          if (index == colIndexList.value[1]) {
            itemvalue.scheduleId.forEach((item, index) => {
              if (index <= indexValList.value[1]) {
                item.scheduledId = "true";
              }
            });
          }
          if (index > Number(colIndexList.value[0]) && index < Number(colIndexList.value[1])) {
            itemvalue.scheduleId.forEach((item, index) => {
              item.scheduledId = "true";
            });
          }
        });
      }
    }
  }
};
const chineseDateToISO8601 = chineseDate => {
  const regex = /(\d{4})年(\d{2})月(\d{2})日/;
  const match = chineseDate.match(regex);
  if (match) {
    const [_, year, month, day] = match;
    const date = new Date(Number(year), Number(month) - 1, Number(day));
    // const isoString = date.toISOString().split("T")[0];
    return date.getTime();
  } else {
    throw new Error("时间格式错误");
  }
};
const changePhotoList2 = val => {
  equipdata.value.legalAttachment = val;
};
const changePhotoList3 = val => {
  equipdata.value.specificWeightPhoto = val;
};
// 新的文件列表
const changeFileList = val => {
  equipdata.value.testingFile = val;
};
/** 提交按钮 */
const subLoading = ref(false);
const equipopenDetailsubmitForm = async (formEl: any) => {
  if (!formEl) return;
  await formEl.validate(async valid => {
    if (valid) {
      subLoading.value = true;
      const params = {
        id: equipdata.value.id,
        permitOutNumber: equipdata.value.permitOutNumber,
        chemicalCode: equipdata.value.chemicalCode,
        chemical: equipdata.value.chemical,
        purchaseUnit: equipdata.value.purchaseUnit,
        totalQuantity: equipdata.value.totalQuantity,
        // remainQuantity: equipdata.value.remainQuantity,
        effectiveDateFrom: equipdata.value.timevalue[0],
        effectiveDateTo: equipdata.value.timevalue[1],
        limitTimesType: equipdata.value.limitTimesType,
        salesCompany: equipdata.value.salesCompany,
        responsiblePersonId: equipdata.value.responsiblePersonId,
        responsiblePerson: equipdata.value.responsiblePerson,
        updateTime: equipdata.value.updateTime,
        permitAttachment: equipdata.value.permitAttachment,
        legalAttachment: equipdata.value.legalAttachment,
        permitNumber: equipdata.value.permitNumber
      };
      console.log(equipdata.value.timevalue);
      if (equipdata.value.timevalue != null) {
        if (equipdata.value.timevalue.length > 0) {
          params.effectiveDateFrom = equipdata.value.timevalue[0];
          params.effectiveDateTo = equipdata.value.timevalue[1];
        }
      }
      if (buttonTitle.value == "新增") {
        if (params.permitAttachment.length > 0) {
          params.permitAttachment = params.permitAttachment.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        if (params.legalAttachment.length > 0) {
          params.legalAttachment = params.legalAttachment.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }

        precursorChemicalPurchasePermitadd(params)
          .then((response: any) => {
            PxMessage({
              message: `${buttonTitle.value == "新增" ? "添加成功" : "修改成功"}`,
              type: "success"
            });
            resetQuery();
            subLoading.value = false;
            equipopenDetail.value = false;
          })
          .catch(() => {
            subLoading.value = false;
          });
      } else {
        if (params.permitAttachment.length > 0) {
          params.permitAttachment = params.permitAttachment.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        if (params.legalAttachment.length > 0) {
          params.legalAttachment = params.legalAttachment.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        precursorChemicalPurchasePermitupdate(params)
          .then((response: any) => {
            PxMessage({
              message: `${buttonTitle.value == "新增" ? "添加成功" : "修改成功"}`,
              type: "success"
            });
            resetQuery();
            subLoading.value = false;
            equipopenDetail.value = false;
          })
          .catch(() => {
            subLoading.value = false;
          });
      }
    }
  });
};
/** 删除按钮操作 */
function handleDelete(row) {
  //console.log(row);
  // const dictIds = [];
  // if (row.equipmentId != undefined) {
  //   dictIds.push(row.equipmentId);
  // } else {
  //   dictIds.push(...ids.value);
  // }
  PxMessageBox.confirm("是否确认删除？", "温馨提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
    draggable: true
  })
    .then(async () => {
      const data = await scheduledelete({ id: row.id });
      PxMessage({
        message: "删除成功",
        type: "success"
      });
      handleDetail(appearanceSelect.value);
    })
    .catch(() => {});
}
const { VITE_FANRUAN_BASE_URL, VITE_SERVE_API_STATIC_URL } = import.meta.env;
/** 导出按钮操作 */
function handleExport() {
  if (dateRange.value != null && dateRange.value.length > 0) {
    let Token = getToken().accessToken || "";
    // proxy.download("post", "/operation/api/v1/water/testQuality/pwMetalImpurity/export", queryParams.value, "水质检测-纯水金属阴阳离子.xlsx");
    let url = `${VITE_FANRUAN_BASE_URL}/webroot/decision/view/report?viewlet=water%252F%25E5%2585%25B6%25E4%25BB%2596%25E5%258C%2596%25E5%25AD%25A6%25E5%2593%2581%25E8%25BD%25BD%25E8%25BF%259B%25E5%258F%25B0%25E8%25B4%25A6-FAC%2BWater.cpt&token=${Token}&from=${dateRange.value[0]}&to=${dateRange.value[1]}&chemical=${queryParams.value.chemical}&systemCode=${queryParams.value.systemCode}&location&format=excel&extype=simple&apiHost=${VITE_SERVE_API_STATIC_URL}`;
    window.location.href = url;
  } else {
    PxMessage({
      message: "请选择时间后再导出",
      type: "error"
    });
  }
}
</script>
<style scoped lang="scss">
.addEquip {
  position: absolute;
  top: 0;
  top: 5px;
  left: 0;
  width: calc(100% - 48px);
  height: calc(100% - 40px);
  margin: 24px;
  background: white;
}

.editorEquip {
  position: absolute;
  top: 0;
  top: 5px;
  left: 0;
  width: calc(100% - 48px);
  height: calc(100% - 40px);
  margin: 24px;
  background: white;
}

.px-dialog-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 2002;
  width: 100%;
  height: 50px;
  padding-top: 10px;
  padding-right: 34px;
  text-align: right;
  background: white;
  box-shadow: 0 0 10px 0 rgb(0 0 0 / 16%);
}

.card-header {
  min-height: 40px;
  padding: 14px 15px 7px !important;
  cursor: pointer;
  user-select: none;
  background: #e7eefb;
}

.card-title {
  float: left;
  line-height: 14px;
}

.card-main {
  float: left;
  margin: -3px 8px 0 5px;
  cursor: pointer;
}

.box-card1 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card2 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card3 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card4 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.demo-form-inline {
  .px-input {
    --px-input-width: calc(100% - 100px);
  }

  .px-form-item {
    width: 100%;
  }

  .px-textarea__inner {
    width: calc(100% - 100px) !important;
  }

  .px-form-item__label {
    font-weight: 400 !important;
  }
}

.form-div {
  padding: 24px;

  .px-row {
    margin-bottom: 16px;
  }
}

.px-icon {
  font-size: 16px !important;
}

:deep(.px-tabs__header) {
  // padding-left: 6px !important;
}

:deep(.px-tabs--top .px-tabs__item.is-top.is-active) {
  border: none;

  .pane-bottom {
    line-height: 30px;
    border-bottom: 2px solid #3b82f6;
  }
}

:deep(.px-tabs .px-tabs__item) {
  .pane-bottom {
    line-height: 30px;
  }
}

.pane-line {
  position: absolute;
  top: 12px;
  right: 0;
  height: 15px;
  color: #dcdcdc;
  border-left: 1px solid #dcdcdc;
}

:deep(.custom-form-ui .px-form-item) {
  width: 250px !important;
}

:deep(.px-upload-list--picture-card .px-upload-list__item) {
  width: 96px;
  height: 96px;
}

.filename {
  position: absolute;
  bottom: -30px;
  width: 96px;
  overflow: hidden;
  color: rgb(166 167 172);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:deep(.px-descriptions__label.px-descriptions__cell.is-bordered-label) {
  width: 166px;
  background: #e7eefb;
  border: 1px solid #dfdfdf;
}

:deep(.px-descriptions__body .px-descriptions__table.is-bordered .px-descriptions__cell) {
  border: 1px solid #dfdfdf;
}

.cell-item {
  text-align: right;
}

:deep(.px-table__cell) {
  height: 36px;
  padding: 0;
  line-height: 36px;

  .cell {
    height: 36px;
    line-height: 36px;
  }
}

:deep(.px-table__header) {
  thead {
    tr {
      background-color: #e7eefb !important;

      th {
        font-size: 14px;
        font-weight: bold;
        color: #000;
        background-color: #e7eefb !important;
      }
    }
  }
}

:deep(.px-table--isfixedHeader .px-table__header-wrapper .px-table-fixed-column--right) {
  background-color: #e7eefb !important;
}

.center2 {
  :deep(.px-descriptions__body) {
    table {
      border-left: none;

      .is-bordered-label {
        border-left: none !important;
      }
      // .is-bordered-content {
      //   border-right: none !important;
      // }
    }
  }
}

.status-value {
  color: #10b981;
}

.status-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: #10b981;
  border-radius: 50%;
}

.status-value2 {
  color: red;
}

.status-icon2 {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: red;
  border-radius: 50%;
}

.spanhover {
  position: absolute;
  top: -1px;
  left: -1px;
  display: inline-block;
  width: 53px;
  height: 40px;
  cursor: pointer;
}

.spandisabled {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  width: 52px;
  height: 39px;
  background: #e9f8f9;
}

.spandisabled2 {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  width: 52px;
  height: 39px;
  background: #fff9e6;
}
</style>
